<template>
  <view class="com-a-page">
    <view class="header">
      <text>组件A独立页面</text>
    </view>
    
    <view class="content">
      <view class="data-section">
        <text>当前数据：{{ localData }}</text>
      </view>
      
      <button @click="sendToComB" type="primary">发送数据到组件B</button>
      <button @click="goBack" size="mini">返回首页</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      localData: '来自ComA页面的数据'
    }
  },
  onLoad() {
    console.log('组件A页面加载')
  },
  methods: {
    sendToComB() {
      uni.$emit('pageComAToComB', {
        message: this.localData,
        timestamp: new Date().getTime()
      })
      uni.showToast({
        title: '数据已发送到组件B',
        icon: 'success'
      })
    },
    goBack() {
      uni.navigateBack()
    }
  }
}
</script>

<style>
.com-a-page {
  padding: 30rpx;
}

.header {
  font-size: 36rpx;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30rpx;
}

.content {
  padding: 20rpx;
}

.data-section {
  margin: 20rpx 0;
  padding: 15rpx;
  background-color: #fffacd;
  border-radius: 8rpx;
}
</style>